//
//  YLLBassTableViewController.swift
//  YLLSina
//
//  Created by 于玲玲 on 16/7/28.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class YLLBassTableViewController: UITableViewController ,YLLVisitorViewDelegate{

    let visitor = YLLVisitorView()
    
        var token: String = YLLLoginViewModel.shareInstance.access_token ?? ""
    
    override func loadView() {
        
        
        if YLLLoginViewModel.shareInstance.isLogin {
            super.loadView()
        }else{
            
            view = visitor
            
            visitor.delegate = self
            
            setupNav()
        }
        
  
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()


    }
    
    private func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "didRegisterMethod")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "login")
        
    }
     // 在运行时的时候,去点击button/发送通知 等交互方法,设置成private的话,系统会找不到这个方法,我们可以用 @objc,帮助系统来查找这个方法
    @objc private func login(){
        printLog("有些私有方法,在运行时的时候要特殊处理一下")
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



}


//什么时候用扩展啊
//为什么printLog不打印qa
extension YLLBassTableViewController{
    
    func didLoginMethod() {
        printLog("登录回调")
    }
    
    func didRegisterMethod() {
        printLog("注册回调")
        
        let login = YLLLoginViewController()
        
        let nav = UINavigationController(rootViewController: login)
        
        presentViewController(nav, animated: true) { 
            
        }
        
        
    }
    
}


